#ifndef UUID_4EA0F741491249597AB4C89F8050A9CE
#define UUID_4EA0F741491249597AB4C89F8050A9CE

#include "tl/platform.h"
#include "tl/cstdint.h"

#if TL_WINDOWS
#	ifdef SFX_EXPORTS
#		define SFX_API __declspec(dllexport)
#	else
#		define SFX_API __declspec(dllimport)
#	endif
#else
#	define SFX_API
#endif

#define COMMON_SFX_BASE() \
	char dummy;

typedef struct sfx
{
	COMMON_SFX_BASE()
} sfx;

typedef struct sfx_device
{
	char* name;
	int max_out_channels;
	double default_sample_rate;
} sfx_device;

typedef struct sfx_stream
{
	unsigned sample_rate;
	int outputIsRunning;
	unsigned int successfulCalls;
	int outputUnderflowCount;
	uint32_t stream_pos;
	int16_t* buffer;
	void* ud;
	void (*fill)(struct sfx_stream* str, uint32_t start, uint32_t frames);
	sfx* owner;
} sfx_stream;

SFX_API sfx* sfx_create(void);
SFX_API sfx_stream* sfx_open(sfx* self, void(*fill)(sfx_stream* str, uint32_t start, uint32_t frames));
SFX_API double sfx_get_time(sfx* self);

SFX_API int sfx_start(sfx_stream* str);
SFX_API int sfx_stop(sfx_stream* str);
SFX_API void sfx_stream_destroy(sfx_stream* str);
SFX_API uint32_t sfx_stream_get_pos(sfx_stream* self);

/* Speaker Positions: */
#define PAWIN_SPEAKER_FRONT_LEFT				((unsigned long)0x1)
#define PAWIN_SPEAKER_FRONT_RIGHT				((unsigned long)0x2)
#define PAWIN_SPEAKER_FRONT_CENTER				((unsigned long)0x4)
#define PAWIN_SPEAKER_LOW_FREQUENCY				((unsigned long)0x8)
#define PAWIN_SPEAKER_BACK_LEFT					((unsigned long)0x10)
#define PAWIN_SPEAKER_BACK_RIGHT				((unsigned long)0x20)
#define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER		((unsigned long)0x40)
#define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER		((unsigned long)0x80)
#define PAWIN_SPEAKER_BACK_CENTER				((unsigned long)0x100)
#define PAWIN_SPEAKER_SIDE_LEFT					((unsigned long)0x200)
#define PAWIN_SPEAKER_SIDE_RIGHT				((unsigned long)0x400)
#define PAWIN_SPEAKER_TOP_CENTER				((unsigned long)0x800)
#define PAWIN_SPEAKER_TOP_FRONT_LEFT			((unsigned long)0x1000)
#define PAWIN_SPEAKER_TOP_FRONT_CENTER			((unsigned long)0x2000)
#define PAWIN_SPEAKER_TOP_FRONT_RIGHT			((unsigned long)0x4000)
#define PAWIN_SPEAKER_TOP_BACK_LEFT				((unsigned long)0x8000)
#define PAWIN_SPEAKER_TOP_BACK_CENTER			((unsigned long)0x10000)
#define PAWIN_SPEAKER_TOP_BACK_RIGHT			((unsigned long)0x20000)

/* Bit mask locations reserved for future use */
#define PAWIN_SPEAKER_RESERVED					((PaWinWaveFormatChannelMask)0x7FFC0000)

/* Used to specify that any possible permutation of speaker configurations */
#define PAWIN_SPEAKER_ALL						((PaWinWaveFormatChannelMask)0x80000000)

/* DirectSound Speaker Config */
#define PAWIN_SPEAKER_DIRECTOUT					0
#define PAWIN_SPEAKER_MONO						(PAWIN_SPEAKER_FRONT_CENTER)
#define PAWIN_SPEAKER_STEREO					(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
#define PAWIN_SPEAKER_QUAD						(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_BACK_LEFT  | PAWIN_SPEAKER_BACK_RIGHT)
#define PAWIN_SPEAKER_SURROUND					(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
#define PAWIN_SPEAKER_5POINT1					(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
												PAWIN_SPEAKER_BACK_LEFT  | PAWIN_SPEAKER_BACK_RIGHT)
#define PAWIN_SPEAKER_7POINT1					(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
												PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
												PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
#define PAWIN_SPEAKER_5POINT1_SURROUND			(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
												PAWIN_SPEAKER_SIDE_LEFT  | PAWIN_SPEAKER_SIDE_RIGHT)
#define PAWIN_SPEAKER_7POINT1_SURROUND			(PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
												PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
												PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
												PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)

#endif // UUID_4EA0F741491249597AB4C89F8050A9CE
